<!DOCTYPE html>
<html xmlns:style="http://www.w3.org/1999/xhtml">
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>echarts02</title>
    <meta name="description" content="echarts02">
    <meta name="keywords" content="echarts02">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/echarts/echarts.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>统计分析<small>套餐收入占比</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>套餐收入占比</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div style="width: 1200px ;height:80px" align="center">
                <span class="demonstration"></span>
                <el-date-picker
                        v-model="dateValue"
                        type="daterange"
                        align="center"
                        unlink-panels
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        :picker-options="pickerOptions">
                </el-date-picker>
                <br>
                <el-button type="primary" @click="certain()">生成饼形图</el-button>
            </div>
        </div>
    </div>
</div>
<div id="chart"  style=" width: 1200px; height: 400px;"></div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var myChart = echarts.init(document.getElementById('chart'));
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                pickerOptions: {
                    shortcuts: [{
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                dateValue: [],
            };
        },
        created() {
            this.certain();
        },
        methods: {
            certain() {

                axios.post("/reportIncome/action.do",this.dateValue).then((res)=>{
                    myChart.setOption({
                        title : {
                            text: '套餐收入占比',
                            subtext: '',
                            x:'center'
                        },
                        tooltip : {//提示框组件
                            trigger: 'item',//触发类型，在饼形图中为item
                            formatter: "{a} <br/>{b} : {c} ({d}%)"//提示内容格式
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            data: res.data.data.MealNames
                        },


                        // series : [
                        //     {
                        //         name: '套餐收入占比',
                        //         type: 'pie',
                        //         radius : '55%',
                        //         center: ['50%', '60%'],
                        //         data:res.data.data.MealIncomes,
                        //         itemStyle: {
                        //             emphasis: {
                        //                 shadowBlur: 10,
                        //                 shadowOffsetX: 0,
                        //                 shadowColor: 'rgba(0, 0, 0, 0.5)'
                        //             }
                        //         }
                        //     }
                        // ]


                        series: [
                            {
                                name: '套餐收入占比',
                                type: 'pie',
                                radius: ['50%', '70%'],
                                avoidLabelOverlap: false,
                                label: {
                                    show: false,
                                    position: 'center'
                                },
                                emphasis: {
                                    label: {
                                        show: true,
                                        fontSize: '20',
                                        fontWeight: 'bold'
                                    }
                                },
                                labelLine: {
                                    show: false
                                },
                                data:res.data.data.MealIncomes,
                            }
                        ]


                    });
                });

            },
        },

    })
</script>
</html>
